package net.zoneland.zrdp.common.utils;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.nio.file.Paths;


class ServletUtilsTestCase {

    @Test
    void testUrlEnDecode() {
        final String[] samples = {"A", "", "-"};
        for (final String input : samples) {
            final String ret = ServletUtils.urlEncode(input);
            final String src = ServletUtils.urlDecode(ret);
            Assertions.assertEquals(input, src);
        }
    }
    @Test
    void testPathResolve() {
        final Path basePath = Paths.get("test/testdir");
        final String downloadPath = "../targetdir";
        final Path normalizedPath = basePath.resolve(downloadPath).normalize();
        Assertions.assertEquals(Paths.get("test/targetdir"), normalizedPath);
    }

}
